package cn.wolfcode.trip.base.domain;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;
import lombok.Setter;
import org.springframework.util.StringUtils;

import java.util.Date;

@Getter
@Setter
public class StrategyComment extends BaseDomain{
    public static final Integer STATE_DISABLED = -1;   // 禁用
    public static final Integer STATE_DEFAULT = 0;     // 默认
    public static final Integer STATE_HOT = 1;     // 推荐

    // 用户
    private User user;
    // 创建时间
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private Date createTime;
    // 内容
    private String content;
    // 图片
    private String imgUrls;
    // 星星数量
    private Integer starNum;
    // 所属攻略
    private Strategy strategy;
    // 状态
    private Integer state = STATE_DEFAULT;
    // 评论时间
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private Date commendTime;

    public String[] getImgUrlsArr() {
        if(StringUtils.hasLength(imgUrls)) {
            return imgUrls.split(";");
        }
        return null;
    }
}